package xyz.zdsoft.ask_for_leave_manage_module.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.ask_for_leave_manage_module.bo.AdminStudentLeaveRecordsBo;
import xyz.zdsoft.ask_for_leave_manage_module.service.impl.AdminLeavesServiceImpl;
import xyz.zdsoft.ask_for_leave_manage_module.vo.AdminStudentLeaveRecordsVo;
import xyz.zdsoft.ask_for_leave_manage_module.vo.AdminStudentLeavesDetailsVo;
import xyz.zdsoft.common.utils.Result;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 管理员-请假记录模块
 * @author 以风
 */
@RestController
@Api(tags = "管理员-请假记录")
@RequestMapping("/api/admin/adminLeavesController")
public class AdminLeavesController {
    @Resource
    private AdminLeavesServiceImpl adminLeavesService;

    @ApiOperation(value = "获取学生请假记录分页信息列表（查询、分页、重置）")
    @PostMapping("/getStudentLeaveRecordsPage")
    public Result<IPage<AdminStudentLeaveRecordsVo>> getStudentLeaveRecordsPage(AdminStudentLeaveRecordsBo adminStudentLeaveRecordsBo){
        IPage<AdminStudentLeaveRecordsVo> page = new Page<>(adminStudentLeaveRecordsBo.getCurrent(),adminStudentLeaveRecordsBo.getSize());
        IPage<AdminStudentLeaveRecordsVo> adminStudentLeaveRecordsVoIPage = adminLeavesService.getStudentLeaveRecordsPage(page,adminStudentLeaveRecordsBo);
        return Result.ok().message("获取学生请假记录分页信息列表成功").data(adminStudentLeaveRecordsVoIPage);
    }

    @ApiOperation(value = "详情")
    @GetMapping("/getStudentLeaveDetails")
    @ApiImplicitParam(name = "leaveId",value = "请假id",required = true)
    public Result<Map<String,Object>> getStudentLeaveDetails(Integer leaveId){
       Map<String,Object> resultMap = adminLeavesService.getStudentLeaveDetails(leaveId);
        return Result.ok().message("获取学生请假详情成功").data(resultMap);
    }
}
